/*
 * 类名称:ShopsAnnouncementServiceImpl.java
 * 包名称:com.platform.service.impl
 *
 * 修改履历:
 *     日期                       修正者        主要内容
 *     2019-08-28 11:44:25        lipengjun     初版做成
 *
 * Copyright (c) 2019-2019 微同科技
 */
package com.platform.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.utils.QueryPlus;
import com.platform.dao.ShopsAnnouncementDao;
import com.platform.entity.ShopsAnnouncementEntity;
import com.platform.service.ShopsAnnouncementService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * 店铺公告列表Service实现类
 *
 * @author sunkaichun
 * @date 2019-08-28 11:44:25
 */
@Service("shopsAnnouncementService")
public class ShopsAnnouncementServiceImpl extends ServiceImpl<ShopsAnnouncementDao, ShopsAnnouncementEntity> implements ShopsAnnouncementService {

    @Override
    public List<ShopsAnnouncementEntity> queryAll(Map<String, Object> params) {
        return baseMapper.queryAll(params);
    }

    @Override
    public Page queryPage(Map<String, Object> params) {
        //排序
        params.put("sidx", "T.id");
        params.put("asc", false);
        Page<ShopsAnnouncementEntity> page = new QueryPlus<ShopsAnnouncementEntity>(params).getPage();
        return page.setRecords(baseMapper.selectShopsAnnouncementPage(page, params));
    }

    @Override
    public boolean add(ShopsAnnouncementEntity shopsAnnouncement) {
        return this.save(shopsAnnouncement);
    }

    @Override
    public boolean update(ShopsAnnouncementEntity shopsAnnouncement) {
        return this.updateById(shopsAnnouncement);
    }

    @Override
    public boolean delete(Integer id) {
        return this.removeById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteBatch(Integer[] ids) {
        return this.removeByIds(Arrays.asList(ids));
    }
}
